package com.cyh.FieldConstructInitiationOrder;

import java.util.Date;
import java.util.concurrent.TimeUnit;

/**
 * Created by yanhuche on 2/24/2017.
 */
public class InitiationOrder {

    private static final Test test = new Test("static final");

    private final Test test2;

    private Test test3 = new Test("normal field");
    private Test test4 = new Test("normal field_2");

    public InitiationOrder(Test test2) {
        System.out.println(new Date() + " before construct");
        this.test2 = test2;
        System.out.println(new Date() + " after construct");
    }

}


class Test {

    public Test(String who) {
        System.out.println(new Date() + "  " + who);
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
